#include <iostream>
using namespace std;
const int BUFFER_SIZE = 32;
/*无参构造函数想要调用有参构造函数必须使用初始化列表*/
class Person
{
public:
#if 1
    Person()
    {
        cout << "父类无参构造\n";
        m_addr = new char[BUFFER_SIZE];
    }
#endif
    ~Person()
    {
        cout << "父类析构函数\n";
        if (m_addr != nullptr)
        {
            delete[] m_addr;
            m_addr = nullptr;
        }
    }
    Person(int age) : m_age(age)
    {
        cout << "父类带参构造\n";
    }

private:
    int m_age;
    char *m_addr;
};
class Student : public Person
{
public:
    Student()
    {
        cout << "子类无参构造\n";
        m_name = new char[BUFFER_SIZE];
    }
    ~Student()
    {
        cout << "子类析构函数\n";
        if (m_name != nullptr)
        {
            delete[] m_name;
            m_name = nullptr;
        }
    }

public:
    int m_no;
    char *m_name;
};
int main()
{
    /*子类构造函数默认会调用父类的无参构造函数*/
    Student stu;
    cout << stu.m_no << endl;
    return 0;
}